#include "CommandInvoker.h"

CommandInvoker::CommandInvoker()
{
}

CommandInvoker::~CommandInvoker()
{
    clearCommands();
}

void CommandInvoker::addCommand(Command *cmd) 
{   
    m_commandList.push_back(cmd);
}

void CommandInvoker::executeCommands() 
{
    for (auto &cmd : m_commandList)
        if(cmd) cmd->execute();

    clearCommands();
}

void CommandInvoker::clearCommands()
{
    for (auto &cmd : m_commandList) delete cmd;
    m_commandList.clear();
}

bool CommandInvoker::isCmdListEmpty()
{
    return m_commandList.empty();
}
